{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加参数</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">类别：</label>
                            <div class="layui-input-block">
                                <select name="car_type_id"  xm-select-search="" xm-select-radio="" xm-select-search-type="dl" lay-search="" id="car_type_id"  lay-filter="car_type_id">
                                    <option value="" >---- 类别 ----</option>
                                    {foreach name="car_type" item="v1"}
                                    <option value="{$v1.c_type_id}" >{$v1.c_type_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="cate_goods">
                            <label class="layui-form-label">属性：</label>
                            <div class="layui-input-block">
                                <select name="car_param_id" xm-select="select2" xm-select-search="" id="car_param_id">
                                    <option value="" >---- 属性 ----</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">添加
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
//    var editor = wk.wang({elem:'#LAY_editor'});
//    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
//        form.verify({
//            editor:function(value,item){
//                if(editor.txt.html() == '<p><br></p>'){
//                    return '请填写内容';
//                }
//            }
//        });
        form.on('submit(component-form-element)', function (data) {
//            data.field.new_content = editor.txt.html();
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('typeadd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Car/typeIndex')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
<script>
    // 根据类别获取属性
    //layui分类
    layui.use(['form'], function() {
        var form = layui.form
                , layer = layui.layer
        form.on('select(car_type_id)', function(data){
            getParams(data.value);
        });
        function getParams(id){
            $.ajax({
                url:"{:url('admin/Base/getParam')}",
                dataType:"json",
                data:'id='+id,
                type:'post',
                success:function(res){
                    layui.formSelects.data('select2', 'local', {
                        arr: res.msg
                    });
                }
            })
        }
    })
</script>

</body>
</html>
